package com.thoughtworks.jspecsupport.settings;

import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.openapi.project.Project;

@State(
        name = "JSpecSupportSettings",
        storages = {@Storage(
                id = "other",
                file = "$WORKSPACE_FILE$")})
public class JSpecSupportSettings implements PersistentStateComponent<JSpecSupportSettings> {

    private String prodJsFolder;
    private String testLibFolder;    // /home/isaachan/opensrc/JSpecPlugin/rhinoextension/js/jspec.js

    public static JSpecSupportSettings getInstance(Project project) {
        return ServiceManager.getService(project, JSpecSupportSettings.class);
    }

    public JSpecSupportSettings getState() {
        System.out.println("getState: " + this);
        return this;
    }

    public void loadState(JSpecSupportSettings settings) {
        System.out.println("loadState: " + settings);
        this.prodJsFolder = settings.prodJsFolder;
        this.testLibFolder = settings.testLibFolder;
    }

    public String getProdJsFolder() {
        return prodJsFolder;
    }

    public void setProdJsFolder(String prodJsFolder) {
        this.prodJsFolder = prodJsFolder;
    }

    public String getTestLibFolder() {
        return testLibFolder;
    }

    public void setTestLibFolder(String testLibFolder) {
        this.testLibFolder = testLibFolder;
    }

    public String toString() {
        return "[" + prodJsFolder + ", " + testLibFolder + "]";
    }

}
